package com.woniu.map.controller;

import com.woniu.internalcommon.constant.CommonStatusEnum;
import com.woniu.internalcommon.dto.POIType;
import com.woniu.internalcommon.dto.ResponseResult;
import com.woniu.map.service.POITypeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("pointType")
public class POITypeController {
    @Resource
    private POITypeService poiTypeService;
    /**
     *
     * @param parentCode
     * @param level
     * @return
     */
    @GetMapping("getSonPoi")
    public ResponseResult<POIType> getSonPoi(@RequestParam("parentCode")  String parentCode
                                            ,@RequestParam("level") String level){

        List<POIType> result = poiTypeService.getPOITypeListByParentCode(parentCode, level);
        return result== null ?
                ResponseResult.fail(CommonStatusEnum.MAP_DISTRICT_ERROR.getCode())
                :ResponseResult.success(result);


    }

    /**
     * 获取 poi 等级
     * @param level poi等级
     * @return
     */

    @GetMapping("getPoint")
    public ResponseResult<List<POIType>> getPOITypeListByLevel(
            @RequestParam("level") String level){

        List<POIType> result = poiTypeService.getPOITypeListByLevel(level);
        return result == null ?
                ResponseResult.fail(CommonStatusEnum.MAP_DISTRICT_ERROR.getCode())
                :ResponseResult.success(result);
    }
    /**
     * 查询所有名字

     */
    @GetMapping("getAllPOITypeNames")
    public ResponseResult<List<String>> getAllPOITypeNames(){
        List<String> result = poiTypeService.getAllPOITypeNames();
        return result == null ?
                ResponseResult.fail(CommonStatusEnum.MAP_DISTRICT_ERROR.getCode())
                :ResponseResult.success(result);
    }


}
